***Marginal Effects Estimates - Macmillan to Major***
***Columns 4/5 of Table 3***
***Syntax Derived from Matt Golder's code for Brambor, Clark, and Golder (2006)***
#delimit ;
version 8.0;
use "C:\Users\fosterdm\Desktop\Foster_Keller II.dta";
logit ukmidinit mul_py mpy2 mpy3 relpow lndist tradevol polity_j PMP_seats Lab elect UKwar ann_misery distrust distrust_mis, nolog cl(ccode2) robust;
preserve;
drawnorm b1-b15, n(1000) means(e(b)) cov(e(V)) clear;
postfile mypost predv_1 lo1 hi1 predv_2 lo2 hi2 diff1_2 difflo1_2 diffhi1_2 using "C:\Users\fosterdm\Desktop\churchill to blair", replace;
noisily display "start";
            
scalar h_py=24.1;
scalar h_y2=869;
scalar h_y3=36909;
scalar h_dist=7.96;
scalar h_relpow=.896;
scalar h_trade=1628;
scalar h_dem=0;
scalar h_elec=0;
scalar h_war=0;
scalar h_seats=.565;
scalar h_lab=0;
scalar h_constant=1;

generate x_betahat1 = b1*h_py+b2*h_y2+b3*h_y3+b4*h_relpow+b5*h_dist+b6*h_trade+b7*h_dem+b8*h_seats+b9*h_lab+b10*h_elec+b11*h_war+b12*2.4+b13*0.1223+b14*2.4*0.1223+b15*h_constant;
generate x_betahat2 = b1*h_py+b2*h_y2+b3*h_y3+b4*h_relpow+b5*h_dist+b6*h_trade+b7*h_dem+b8*h_seats+b9*h_lab+b10*h_elec+b11*h_war+b12*8.2+b13*0.1212+b14*8.2*0.1212+b15*h_constant;


gen pr1=exp(x_betahat1)/(1+exp(x_betahat1));
gen pr2=exp(x_betahat2)/(1+exp(x_betahat2));

gen d1_2=pr2-pr1;

egen p_v_1=mean(pr1);
egen p_v_2=mean(pr2);

egen d_f1_2=mean(d1_2);


tempname postfile mypost predv_1 lo1 hi1 predv_2 lo2 hi2 diff1_2 difflo1_2 diffhi1_2;
_pctile pr1, p(10,90);
scalar `lo1' = r(r1);
scalar `hi1' = r(r2);  
_pctile pr2, p(10,90);
scalar `lo2' = r(r1);
scalar `hi2' = r(r2);  

_pctile d1_2, p(10,90);
scalar `difflo1_2' = r(r1);
scalar `diffhi1_2' = r(r2);  
   
scalar `predv_1' = p_v_1;
scalar `predv_2' = p_v_2;

scalar `diff1_2' = d_f1_2;

post mypost (`predv_1') (`lo1') (`hi1') (`predv_2') (`lo2') (`hi2') (`diff1_2') (`difflo1_2') (`diffhi1_2');
     
***Estimates output to "churchill to blair.dta"; transferred manually to Excel Spreadsheet for graphing***



